
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DeviceService } from "./app.service";
import websocket from "./websocket";

async function bootstrap() {

  const port = 3000;

  const app = await NestFactory.create(AppModule);
  app.enableCors();
  await app.listen(port);

  console.log(`http服务启动成功：端口：${port}`);

  // 启动设备
  const deviceService = app.get(DeviceService);
  await deviceService.publishAll();

  websocket.start();

  console.log('硬件服务启动成功');

}
bootstrap().then(()=>{

}).catch(e=>{
  console.error(e);
});
